<?php   
error_reporting(E_ALL ^ E_NOTICE);
ini_set('memory_limit', '1000M'); 
set_time_limit(0);
CONST TYPE_NORMAL = 1;
CONST TYPE_BAD = 2;
while (($line_json = fgets(STDIN)) !== false) {   //line_json=>source_url\tjson��ʽ
    $line_json = trim($line_json);
    if (empty($line_json))
        continue;
    list ($key, $list_json) = explode("\t", $line_json);
    list ($key,$sub_key) =  explode(".",$key);
    $house_info = json_decode($list_json, true);
    if ($last_key == $key and ($last_info['house_totalarea']==$house_info['house_totalarea'] and (abs($last_info['house_price'] - $house_info['house_price']) < 1))){
        echo $last_id."\t".$house_info['id']."\n";
	echo $last_info['source_url']."\t".$house_info['source_url']."\n";
        $house_info['bad_type'] = 18;
	    $out = json_encode($house_info);
        echo $house_info['source_url']."\t".$out."#B\n";
    }
    else{
	$last_key = $key;
        $last_id = $house_info['id'];
	$last_info = $house_info;
        if($house_info['source'] == 10){
	        echo 'personal'."\t".$list_json."#P\n";
        }
	    else{
	        echo 'broker'."\t".$list_json."#E\n";
        }
    }
}
	     

